# TODO 导入pymysql
import pymysql
# TODO 通过用户名获取用户信息
# TODO 创建连接对象和游标对象
conn = pymysql.connect(user='root', password='root', database='advanced', charset='utf8')
cursor = conn.cursor()
# TODO 执行sql语句
name = input('请输入姓名:')
# name = ' or 1=1 or'  会出现sql注入
sql = f"select * from student where stu_name = '{name}'"
print(sql)
rul = cursor.execute(sql)
if rul:
    student = cursor.fetchall()
    print(student)
else:
    print('没有这个学生信息')
# TODO 关闭资源
cursor.close()
conn.close()
